<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<script language="javascript" type="text/javascript"
			src="<%=basePath%>datemaker/WdatePicker.js">
</script>
		<title>My JSP 'attendanceQuery.jsp' starting page</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<script type="text/javascript" src="<%=basePath%>manage/js/jquery.js"></script>
		<script type="text/javascript" src="manage/js/addbg.js"></script>
		<link rel="stylesheet" type="text/css" href="manage/css/guanli.css"></link>
		<link rel="stylesheet" type="text/css" href="manage/css/search.css"></link>
		<%
			String method = (String) request.getAttribute("methodName");
			if (method == null) {
				method = "queryAll?";
			}
		%>
	</head>

	<body>
		<h2 class="tableTitle">
			考勤展示
		</h2>
		<table class="search">
			<tr>
				<!-- -----------按员工编号查询----------- -->
				<form action="queryById" method="post">
					<input type="hidden" name="page.currentPage" value="1" />
					<td rowspan="2">
						<strong>&nbsp;按员工编号查询</strong>
						<input type="text" name="staffId" value="${staffId}" size="10"/>
					</td>
					<td rowspan="2">
						<input type="submit" value="查询" />&nbsp;&nbsp;&nbsp;
					</td>
				</form>

				<!-- -----------按月汇总----------- -->
				<form action="queryByMonth" method="post">
					<input type="hidden" name="page.currentPage" value="1" />
					<td rowspan="2">
						<strong>按月份汇总</strong>
					</td>

					<td>
						<span style="margin: 0 5px 0 0;" >年份:</span>
						<select name="year" style="margin: 0 5px 0 0;" >
							<%
								Calendar calendar = Calendar.getInstance();
								int nowYear = calendar.get(Calendar.YEAR);
								for (int i = 2000; i <= nowYear; i++) {
							%>
							<option value="<%=i%>"
								<%Object yearObj = request.getAttribute("year");
				String year = null;
				if (yearObj != null)
					year = yearObj.toString();
				if (year != null && i == new Integer(year)) {%>
								selected="selected" <%}%>>
								<%=i%>
							</option>
							<%
								}
							%>
						</select>
						<br />
						<span style="margin: 0 5px 0 0">月份:</span>
						<s:select cssStyle="margin:0 5px 0 0" name="month"
							list="#{1:'1月',2:'2月',3:'3月',4:'4月',5:'5月',6:'6月',7:'7月',8:'8月',9:'9月',10:'10月',11:'11月',12:'12月'}"></s:select>
					</td>

					<td rowspan="2">
						<input type="submit" value="查询" />&nbsp;&nbsp;
					</td>
				</form>

				<!-- -----------按时间区间汇总----------- -->
				<form action="queryByTime" method="post">
					<input type="hidden" name="page.currentPage" value="1" />

					<td rowspan="2">
						<strong>按时间区间汇总</strong>
					</td>

					<td>
						开始时间：
						<input type="text" class="Wdate" onclick="WdatePicker()"
							name="start" value="<s:date name="start" format="yyyy-MM-dd"/>" />
						<br />
						结束时间：
						<input type="text" class="Wdate" onclick="WdatePicker()"
							name="end" value="<s:date name="end" format="yyyy-MM-dd"/>" />
					</td>

					<td rowspan="2">
						<input type="submit" value="查询" />
					</td>

				</form>

				<!-- -----------添加----------- -->
				<form action="" method="post">
					<td colspan="2">
						<input type="button"
							onclick="window.location.assign('manage/attendance/addAttendance.jsp');"
							value="添加" />
					</td>
				</form>

				<s:iterator value="errorList">
					<s:property />
				</s:iterator>
			</tr>
		</table>


		<table class="cssrain">
			<thead>
				<tr>
					<th>
						员工编号
					</th>
					<th>
						员工姓名
					</th>
					<th>
						考勤类型
					</th>
					<th>
						开始时间
					</th>
					<th>
						结束时间
					</th>
					<th>
						应罚金额
					</th>
					<th colspan="2">
						基本操作
					</th>
				</tr>
			</thead>
			<tbody>
				<s:if test="attendanceList != null && !attendanceList.isEmpty()">
					<s:iterator value="attendanceList">
						<s:hidden name="attendance.id" value="%{id}"></s:hidden>
						<tr>
							<td>
								<s:property value="staff.staffId" />
							</td>
							<td>
								<s:property value="staff.name" />
							</td>
							<td>
								<s:property value="type.name" />
							</td>
							<td>
								<s:property value="start" />
							</td>
							<td>
								<s:property value="end" />
							</td>
							<td>
								<s:property value="payment" />
							</td>
							<td>
								<a href="alterAttendance?attendanceId=${id}">修改</a>
							</td>
							<td>
								<a onclick="return confirm('确定要删除吗？')"
									href="deleteAttendance?attendanceId=${id}">删除</a>
							</td>
						</tr>
					</s:iterator>
				</s:if>
				<s:else>
					<tr>
						<td colspan="7">
							没有记录
						</td>
					</tr>
				</s:else>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="8">
						<input type="button" class="firstPage"
							onclick="location.href='<%=method%>page.currentPage=1'"
							value="首页">
						&nbsp;&nbsp;&nbsp;
						<input type="button" class="frontPage"
							onclick="location.href='<%=method%>page.currentPage=${page.currentPage-1}'"
							value="上一页">
						&nbsp;&nbsp;&nbsp;
						<input type="button" class="secondPage"
							onclick="location.href='<%=method%>page.currentPage=${page.currentPage+1}'"
							value="下一页">
						&nbsp;&nbsp;&nbsp;
						<input type="button" class="lastPage"
							onclick="location.href='<%=method%>page.currentPage=${page.totalPages}'"
							value="末页">
						<link rel="stylesheet" type="text/css"
							href="manage/css/tableBanner.css"></link>
					</td>
				</tr>
			</tfoot>
		</table>
		<br />
		<br />
		<h2 class="bannerTitle">
			考勤记录统计
		</h2>
		<table class="cssrain">
			<thead>
				<tr>
					<th>
						迟到
					</th>
					<th>
						早退
					</th>
					<th>
						请假
					</th>
					<th>
						旷工
					</th>
					<th>
						其他
					</th>
					<th>
						扣费金额
					</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<s:if test="typeList != null && !typeList.isEmpty()">
						<s:iterator value="typeList">
						<td>
							<s:property />
						</td>
					</s:iterator>
					</s:if>
					<s:else>
						<td>0</td>
						<td>0</td>
						<td>0</td>
						<td>0</td>
						<td>0</td>
					</s:else>
					<td>
						<s:property value="payment" />
					</td>
				</tr>
			</tbody>
		</table>
	</body>

</html>
